package com.itheima.网络编程.udp编程;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class 组播服务端 {
    public static void main(String[] args) throws IOException {
        MulticastSocket ms = new MulticastSocket(16666);
        ms.joinGroup(InetAddress.getByName("224.0.1.0"));
        while (true) {
            DatagramPacket dp = new DatagramPacket(new byte[1024 * 1024], 1024 * 1024);
            ms.receive(dp);
            System.out.println(new String(dp.getData(), 0, dp.getLength()));
        }
    }
}
